<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateStockTransfersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('stock_transfers', function (Blueprint $table) {
            $table->increments('id');
            $table->string('transfer_no')->default('')->unique()->comment('转移单号');
            $table->integer('out_storage_id')->default(0)->unsigned()->comment('出仓库ID');
            $table->integer('in_storage_id')->default(0)->unsigned()->comment('入仓库ID');
            $table->decimal('total_cost_price',8,2)->default(0.00)->unsigned()->comment('总成本价');
            $table->tinyInteger('status')->default(1)->unsigned()->comment('状态，1-待审核，2-已审核，3-已作废');
            $table->string('remarks',255)->default('')->comment('备注');
            $table->integer('user_id')->default(0)->unsigned()->comment('订单创建操作用户ID');
            $table->timestamp('finished_at')->nullable()->comment('完成时间');
            $table->integer('review_user_id')->default(0)->unsigned()->comment('审核处理人用户ID');
            $table->timestamp('review_at')->nullable()->comment('审核时间');

            $table->timestamps();
        });
        \DB::statement("ALTER TABLE `stock_transfers` comment '库存转移表'");

    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('stock_transfers');
    }
}
